<?php
/**
 * @Author: Marte
 * @Date:   2017-08-14 09:04:07
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-14 14:22:06
 */
session_start();
header('Content-Type:text/html;charset=utf-8');
include "data/config_connect.php";//导入数据库

//如果不存在session，则为非法进入
if(!isset($_SESSION['username']))
{
  echo "<script>alert('请先登录！');window.history.back();</script>";
}

// 获取数据
if(isset($_GET['id']))
{
  $id=$_GET['id'];
  $_sql='select username,nickname,headicon from userregisters where id='.$id.'';
  if(!$_result=$_mysql->query($_sql))
  {
    echo "<script>alert('该用户不存在');window.history.back();</script>";
  }
  else{
    $_result=$_mysql->query($_sql);
    $_assoc=$_result->fetch_assoc();
    //接受方信息
  }
}
else
{
  echo "<script>alert('非法操作');window.history.back();</script>";
}
$sss=$_assoc['username'];//接受评论方的username

$_sql2='select * from comment where receive="'.$sss.'"order by time desc ';
$_result1=$_mysql->query($_sql2);


?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>评论</title>
    <link rel="stylesheet" type="text/css" href="css/send_message.css">
    <script src="js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="plug_ins/wenzi.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
 $(function(){
   //插件
   $(".main").myWords({   //输入框字数
        obj_opts:"textarea",
        obj_Maxnum:400,//要是只能输入140个字  那这里就是280
        obj_Lnum:".sns-num"
    });
})
</script>
</head>
<body>
<div class="main">
    <i class="title"><img src='<?php echo $_assoc['headicon']?>' alt=""></i>
    <span class="to">TO：<?php echo $_assoc['nickname']?></span>
    <form action='data/user/save_cenment.php?action=write' method="post" accept-charset="utf-8">
    <input type="hidden" name="hide" value="<?php echo $_assoc['username']?>">
     <textarea name="content" rows="" class="beizhu" ></textarea>
   <p>
     <span class="sns-num">还能输入<em>210</em>个字</span>
     <input name="提交" type="submit" class="btn" value="发 布"  />
     </form>
   </p>

   <ul class="start">
   <?php

   while ($_assoc1=$_result1->fetch_assoc()) {

    $sql3='select * from userregisters where username="'.$_assoc1['send'].'"';
    $_result2=$_mysql->query($sql3);
    $_assoc3=$_result2->fetch_assoc();



   ?>
       <li>
         <i><img src="<?php echo $_assoc3['headicon']?>" alt=""></i>
        <div class="friend_main_right">
                <span class="username"><?php echo $_assoc3['nickname']?></span><em><img src="images/isgui.png" alt=""></em>
                <p><?php echo $_assoc1['content'];?></p>

                <span class=""><?php echo $_assoc1['time'];?></span>
                <span class="bottom_s not_label1"><a href="" name="" title="">回复</a></span>
                <span class="bottom_s not_label2"><a href="" title="">点赞</a></span>
           </span>
            </div>
            <div class="clear">

            </div>
       </li>
       <?php
        }
       ?>
   </ul>
</div>

</body>
</html>


